/*
 * @Author: tianchunyu
 * @Date: 2020-04-26 20:09:46
 * @LastEditTime: 2020-05-18 17:52:03
 * @LastEditors: Please set LastEditors
 * @Description: This algorithm program provides kalman filtering, incremental PID control algorithm and mean filtering.
 *  Among them, incremental PID algorithm is used for wheel control, kalman filter one-dimensional kalman,
 *
 * @FilePath:
 */
#ifndef _CON_ALGORITHM_H
#define _CON_ALGORITHM_H
#include <stdio.h>
#define SUCCESS (0)
#define FAIL (-1)
/*The following is the pid part code */

typedef struct
{
    float    setpoint;        /*set the target*/
    float    Kp ;             /*proportion */
    float    Ki ;             /*integration */
    float    Kd;              /*differentiation*/
    float    cur_error;       /*the current error  e[0]*/
    float    last_error;      /*the last error  e[-1]*/
    float    prev_error;      /*the Before last error  e[-2]*/
    float    sum_error;       /*erorr sum */
}PIDtypedef;

extern int  PIDx_init(PIDtypedef *PIDx);
extern float PIDx_calc(PIDtypedef*PIDx, float curvalue);
extern int PIDx_setvalue(PIDtypedef*PIDx,float setvalue);
extern int PIDx_setparam(PIDtypedef *PIDx,float kp,float ki,float kd);

extern void sliding_wind_array(int * pointer,int len ,int value);




#endif
